/**
 * Created by ybjaaaaa on 2015/3/25.
 */
define(['jquery'],function($){

    require(["/scripts/commonjs.js"]);

    var user=function(username,role,location){
        return{
            username:username,
            password:'admin',
            role:role,
            location:location
        }
    };

    var users=[new user('Z03148','材料员','/cly-index.html'),
        new user('Z03140','加工厂仓管','/jgccg-index.html'),
        new user('Z03149','安全员','/aqy-index.html'),
        new user('Z03150','质量员','/zly-index.html'),
        new user('Z03151','施工方负责人','/sgffzr-index.html')];

    //登录
    $('#login').click(function(){
        var username=$('#username').val();
        var password=$('#password').val();
        var flag=true;
        users.forEach(function(user,index){
            if(username&&password&&user.username.toLowerCase()==username.toLowerCase()&&user.password.toLowerCase()==password.toLowerCase()){
                window.location.href=user.location;
                flag=false;
            }
        });

        if(flag){
            $.cookie('user',null);
            window['user']=undefined;
            alert('用户名或者密码错误');
        }


    });




});